﻿using System;
using Event.EventBus;

namespace Event.Authentication.EventBusPattern
{
    public class RewardService : IObservedService
    {
        private readonly UserService _userService;
        private readonly IMessenger _messenger;

        public RewardService(UserService userService,IMessenger messenger)
        {
            _userService = userService;
            _messenger = messenger;
        }

        public void RegisterSubject()
        {
            _messenger.Register<UserRegisteredMessage>(_userService, Reward);

        }

        public void Reward(UserRegisteredMessage user)
        {
            if (ShouldReward(user))
            {
                Console.WriteLine("reward successfully");
            }
        }

        private bool ShouldReward(UserRegisteredMessage user)
        {
            return true;
        }

       
    }
}